const { random } = require('./utils.js');
const tips = ['编程代码片段贴近实战，精准提升输入速度！', '想玩游戏没有积分？试着完成练习后再去看看吧～', '自定义内容火热上新，创建教师角色可立即体验哦', '教师角色能力丰富，快去拉群管人建内容吧！', '不清楚按键指法？在帮助-指法查询里都能找到！', '不了解自己的薄弱点？成绩报告的能力分析比你更懂你', ]

function getRandomDesc() {
	const _random = random(0, tips.length - 1);
	return tips[_random];
}
const appellation = [{
	name: '无名小匠',
	desc: '很久没有练习啦，持之以恒才能更好的提升打字速度哦~'
}, {
	name: '打字小匠',
	desc: '坚持练习，定期的练习是保持打字速度和准确性的关键~'
}, {
	name: '打字小将',
	desc: '技能提升，打字速度和准确性都有显著进步的积极练习者~',
}, {
	name: '打字飞侠',
	desc: '敏捷迅速，如飞侠般在键盘上穿梭，打字流畅而准确~'
}, {
	name: '打字达人',
	desc: '技艺精湛，对打字了如指掌，速度和准确性令人钦佩~'
}, {
	name: '键位高手',
	desc: '精准无误，对键位了如指掌，打字速度快且错误率极低~'
}, {
	name: '速度先锋',
	desc: '领先群伦，打字速度遥遥领先，高效且稳定的表现~'
}, {
	name: '打字大师',
	desc: '巅峰造诣，打字艺术的大师级人物，速度与精度完美结合~'
}]
const ranks = [{
	name: '未知等级'
}, {
	name: '未到达评分等级',
	successWpm: [0, 60]
}, {
	name: '初级',
	successWpm: [60, 90],
	accuracyWord: 96
}, {
	name: '中级',
	successWpm: [90, 120],
	accuracyWord: 97
}, {
	name: '高级',
	successWpm: [120, 140],
	accuracyWord: 97
}, {
	name: '速录员-初级',
	successWpm: [140, 180],
	accuracyWord: 95
}, {
	name: '速录员-中级',
	successWpm: [180, 220],
	accuracyWord: 95
}, {
	name: '速录员-高级',
	successWpm: [220, 10000],
	accuracyWord: 95
}]
/**
 * 获取称号及描述等
 * @param {Object} successWpm 正确wpm
 * @param {Object} accuracyWord 打字准确率
 */
function getRank(successWpm, accuracyWord) {
	let _rank = ranks[1].name;
	let _appellation = appellation[1].name;
	if (!successWpm && !accuracyWord) {
		return {
			rank: ranks[0].name,
			appellation: appellation[0]
		}
	}
	for (let i = 0; i < ranks.length; i++) {
		if (i > 0) {
			if (successWpm >= ranks[i].successWpm[0] && successWpm < ranks[i].successWpm[1] && accuracyWord >= ranks[i].accuracyWord) {
				_rank = ranks[i].name;
				_appellation = appellation[i];
			}
		}
	}
	return {
		rank: _rank,
		appellation: _appellation
	}
}
module.exports = {
	getRandomDesc,
	getRank
}